package com.yaoxun.core.resp;

import lombok.Data;

@Data
public class ApiResp<T> {

	private static final String SUCCESS_CODE = "0";
	
	private static final String SUCCESS = "success";
	
	private String retCode;
	
	private String retMsg;
	
	private T data;
	
	public ApiResp() {}
	
	private ApiResp(T data) {
		this.retCode = SUCCESS_CODE;
		this.retMsg = SUCCESS;
		this.data = data;
	}
	
	public ApiResp<T> data(T data) {
		this.data = data;
		return this;
	}
	
	public ApiResp<T> msg(String retMsg) {
		this.retMsg = retMsg;
		return this;
	}
	
	public ApiResp<T> code(String retCode) {
		this.retCode = retCode;
		return this;
	}
	
	public static <T> ApiResp<T> of(T data) {
		return new ApiResp<>(data);
	}
	
}
